package com.mitgroup.dmrvs.view;

import android.content.Intent;
import android.os.Handler;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.mitgroup.dmrvs.R;

public class SplashActivity extends AppCompatActivity implements SplashLoadDataTask.LoadDataCallback {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        // 启动加载应用数据任务类
        SplashLoadDataTask task = new SplashLoadDataTask(this, SplashActivity.this);
        task.execute();
    }
    @Override
    protected void onResume() {
        super.onResume();
    }


    //任务执行完延迟500ms进入主界面
    private void jump(){
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                startActivity(intent);
                SplashActivity.this.finish();
            }
        }, 500);
    }

    @Override
    public void loaded() {
        jump();
    }

    @Override
    public void loadError() {
        this.finish();
    }

    @Override
    public void onBackPressed() {
        // Splash界面不允许使用back键
    }


}

